package com.myblog.controller;

import com.myblog.service.StatisticsService;
import com.myblog.utils.DataMap;
import com.myblog.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class StatisticsController {

    @Autowired
    StatisticsService statisticsService;

    /**
     * 获取后台仪表盘信息
     * @return
     */
    @GetMapping("/getStatisticsInfo")
    public String getStatisticsInfo(){
        try{

            DataMap data = statisticsService.getStatisticsInfo();

            return JsonResult.build(data).toJSON();
        }catch (Exception e){
            log.error("StatisticsController getStatisticsInfo Exception",e);
        }
        return JsonResult.fail().toJSON();
    }
}
